package com.yzd.learnjava.containers;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

import com.yzd.learnjava.util.Countries;
import com.yzd.learnjava.util.Print;


public class CollectionMethods {
	public static void main(String[] args) {
		Collection<String> c = new ArrayList<String>();
		c.addAll(Countries.names(6));
		c.add("ten");
		c.add("eleven");
		Print.print("c : " + c);
		
		Object[] array = c.toArray();
		String[] str = c.toArray(new String[0]);
		
		Print.print("Collections.max(c) : " + Collections.max(c));
		Print.print("Collections.min(c) : " + Collections.min(c));
		
		
		Collection<String> c2 = new ArrayList<String>();
		c2.addAll(Countries.names(6));
		c.addAll(c2);
		Print.print("c add c2 : " + c);
		
		c.remove(Countries.DATA[0][0]);
		Print.print("remove, c : " + c);
		
		c.remove(Countries.DATA[1][0]);
		Print.print("remove, c : " + c);
		
		c.removeAll(c2);
		Print.print("c removeAll c2 : " + c);
		
		c.addAll(c2);
		Print.print("c add c2 : " + c);
		
		String val = Countries.DATA[3][0];
		Print.print("c.contains("+ val + ") = " + c.contains(val));
		
		Collection<String> c3 = ((List<String>)c).subList(3, 5);
		c2.retainAll(c3);
		Print.print("c2 : " + c);
		
		c2.removeAll(c3);
		Print.print("c2.isEmpty() = " + c2.isEmpty());
		
		c = new ArrayList<String>();
		c.addAll(Countries.names(6));
		Print.print("c : " + c);
		c.clear();
		Print.print("after clear , c : " + c);
	}
}
